<?php
require 'Admin/Controller/Controller.php ';
require 'Admin/Model/CarphotoModel.php';
class CarphotoController extends Controller{
		function listcarphoto(){
			$model = new CarphotoModel();
			$data = $model->getCarphotoList();
			//转向用户列表页面
			include 'Admin/View/car/carphotolist.php';
		}

		function carphotoform(){
			//转向添加用户页面
			include 'Admin/View/car/carphotoform.php';
		}

		function carphotoedit(){
			$id = $_GET['id'];
			$model = new CarphotoModel();
			$result = $model->getCarphotoByID($id);
			include 'Admin/View/car/carphotoedit.php';
		}

		function carphotoupdate(){
			$id = $_GET['id'];
			$model = new CarphotoModel();
			$result = $model->Updatecarphoto($id);
			if($result){
				echo '修改成功'.'<a href="admin.php?c=carphoto&m=listcarphoto">如果没有跳转，请点这里跳转</a>';
				header("refresh:3;admin.php?c=carphoto&m=listcarphoto = admin.php?c=carphoto&m=listcarphoto"); 	
			}else{
				echo '失败';
			}
		}

		function delcarphoto(){
			$id = $_GET['id'];
			$model = new Carphotomodel();
			$result = $model->Delcarphoto($id);
			if($result){
				echo '删除成功'.'<a href="admin.php?c=carphoto&m=listcarphoto">如果没有跳转，请点这里跳转</a>';
				header("refresh:3;admin.php?c=carphoto&m=listcarphoto = admin.php?c=carphoto&m=listcarphoto"); 
			}else{
				echo '删除失败';
			}
		}

		function addcarphoto(){
			//获取表单的数据
			//调用model中的addUser方法，添加到数据库中
			//var_dump($_POST);
			$data = $_POST;
			$model = new CarphotoModel();
			$result = $model->addCarphoto($data);
			//如果成功，输出，转到列表页面
			if($result){
				echo '添加成功'.'<a href="admin.php?c=carphoto&m=listcarphoto">如果没有跳转，请点这里跳转</a>';
				header("refresh:3;admin.php?c=carphoto&m=listcarphoto = admin.php?c=carphoto&m=listcarphoto"); 
			}else{
				echo '失败';
			}

		}
	}
 ?>